<template>
  <div>
    <van-nav-bar
  title="我的帖子"
  left-text="返回"
  left-arrow
  @click-left="$router.go(-1)"
/>
<!-- 帖子列表 -->
<div class="post-list">
  <template v-for="nestedArray in PostList">
    <!-- <MyPostItem v-for="item in nestedArray" :item="item" :key="item.postId"></MyPostItem> -->
    <MyPostItem  :item="tdata"></MyPostItem>
  </template>
</div>
  </div>
</template>

<script>
import { mapState} from "vuex";
import MyPostItem from '@/components/MyPostItem.vue';
import {getMyPost} from '@/api/user'
export default {
name:'TieZi',
components:{MyPostItem},
data() {
    return {
      PostList:[],
      tdata:{
  "postId": 45,
  "postTitle": "一起吃饭吧",
  "postContent": "找个人去三餐吃饭",
  "postTime": '2min前',
  "postAvatar": "https://img1.baidu.com/it/u=4200590012,1468804674&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",
  "postNickname": "锺秀兰",
  "postPicture": "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F377d506f-d2f9-4956-8bea-23f2bd67143a%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1715914619&t=46d75337c07815f736dfd8cb954ad2b8",
  "postUid": 51
},
    };
},
computed: {
    //获取存储数据
  ...mapState('user',["userInfo"])
},
async created () {
  try {
    const res = await getMyPost(this.userInfo.userId
);
// console.log(res);
    this.PostList = [res.data];
    console.log('帖子数据',this.PostList);
    if(this.PostList==''){
      this.$toast('您未发布过帖子')
    }
  } catch (error) {
    console.log(error);
  }
  },

methods:{
   
}
}
</script>

<style lang="less" scoped>

</style>